﻿using System.Collections.ObjectModel;
using System.Xml.Serialization;
using ElectronicCommerce.Framework.Configuration.Attributes;

namespace ElectronicCommerce.Framework.Web.Configuration.Website
{
    [XmlRoot("NavList")]
    [ConfigFile("~/Language/zh-CN/Leftnavigation.config", ConfigPathType.ServerPath)]
    public class LeftNavigationConfig
    {
        [XmlElement("Nav")]
        public LeftNavigationCollection NavList
        {
            get;
            set;
        }
    }

    public class NavigationEnity
    {
        [XmlAttribute("id")]
        public int Id
        {
            get;
            set;
        }
        [XmlAttribute("parentId")]
        public int ParentId
        {
            get;
            set;
        }
        [XmlAttribute("iamge")]
        public string Image
        {
            get;
            set;
        }
        [XmlAttribute("pageAlias")]
        public string PageAlias
        {
            get;
            set;
        }
        [XmlAttribute("title")]
        public string Title
        {
            get;
            set;
        }
        [XmlAttribute("text")]
        public string Text
        {
            get;
            set;
        }

        [XmlElement("ChildNAv")]
        public LeftNavigationCollection NavList
        {
            get;
            set;
        }
    }

    public class LeftNavigationCollection : KeyedCollection<int, NavigationEnity>
    {
        protected override int GetKeyForItem(NavigationEnity item)
        {
            return item.Id;
        }
    }
}
